import Vue from 'vue';
import scheduleApi from "@/api/schedule/schedule";

export default Vue.extend({
  template: `
            <div class="custom-tooltip" v-show="visible">
                <p><span>班次名称: </span>{{banciName}}</p>
                <p><span>上班时间: </span>{{sbsj}}</p>
                <p><span>下班时间: </span>{{xbsj}}</p>
            </div>
    `,
    props:{
      
    },
  data: function() {
    return {
      color: null,
      banciName: null,
      sbsj: null,
      xbsj: null,
      visible: true
    };
  },
  beforeMount() {
    let data = this.params.value;
    let bianhao = null;
    // console.log(data);
    if (data != "" && data.indexOf("]") != -1 && data.indexOf("|") != -1) {
      bianhao = data.split("]")[1].split("|")[0];
      scheduleApi.getBanci({bh:bianhao}).then(res => {
        if (res.success) {
            console.log(res.result);
            this.banciName = res.result.banciName;
            this.sbsj = res.result.sbsj;
            this.xbsj = res.result.xbsj;
        }
      });
    } else {
      this.visible = false
    }
		
      
    this.setState(data);
  },
  mounted() {
    // console.log("加载了悬浮提示组件");
  },
  methods: {
    setState(obj) {
      Object.assign(this, obj);
    },
  },
});